package com.iretailer.report.modelMapper;

import com.alibaba.fastjson.JSON;
import org.modelmapper.ModelMapper;
import org.modelmapper.TypeToken;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: xjw
 * @Date: 2019/1/25 10:21
 * @Description:
 */
public class ModelM {
    public static void main(String[] args) {
        Person person1 = new Person("name1", "age1", "hight1");
        Person person2 = new Person("name2", "age2", "hight2");
        List<Person> persons = new ArrayList<>();
        persons.add(person1);
        persons.add(person2);
        ModelMapper modelMapper = new ModelMapper();
        List<Teacher> teachers = modelMapper.map(persons, new TypeToken<List<Teacher>>() {
        }.getType());
        System.out.println(JSON.toJSONString(teachers));
    }
}

class Person {
    private String name;
    private String age;
    private String hight;

    public Person() {
    }

    public Person(String name, String age, String hight) {
        this.name = name;
        this.age = age;
        this.hight = hight;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getHight() {
        return hight;
    }

    public void setHight(String hight) {
        this.hight = hight;
    }
}

class Teacher extends Person {
    private String cla;

    public String getCla() {
        return cla;
    }

    public void setCla(String cla) {
        this.cla = cla;
    }
}
